package priv.menghan.happy.learning.common.rsp;

import lombok.Data;

/**
 * @author Monika
 */
@Data
public class Response<T> {
	private int code;
	private String message;
	private T data;

	public static <T> Response<T> success(T data) {
		Response<T> response = new Response<>();
		response.setCode(200);
		response.setMessage("成功");
		response.setData(data);
		return response;
	}

	public static <T> Response<T> fail(int code, String message) {
		Response<T> response = new Response<>();
		response.setCode(code);
		response.setMessage(message);
		return response;
	}

	public static <T> Response<T> fail(String message) {
		return fail(500, message);
	}
}

